﻿namespace PLCS.Application.Contracts.PLCReadDataApp.Dtos;

public class PLCReadDataEditDto : EntityDto<Guid>
{
    /// <summary>
    /// 字段编号
    /// </summary>
    public string PLCReadDataNo { get; set; }

    public string? PLCConfigNo { get; set; }

    /// <summary>
    /// Desc:开始位
    /// Default:
    /// </summary>
    public int StartBit { get; set; }

    /// <summary>
    /// Desc:结束位
    /// Default:
    /// </summary>
    public int EndBit { get; set; }

    /// <summary>
    /// Desc:读取数据类型
    /// Default:
    /// </summary>
    public Domain.Shared.Enums.DataType DataType { get; set; }

    public int Length { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string Remarks { get; set; }

    /// <summary>
    /// 是否监听
    /// </summary>
    ///
    public YesNo IsDependency { get; set; }

    /// <summary>
    /// 关联的字段名
    /// </summary>
    public string? CorrespondingField { get; set; }

    /// <summary>
    /// 关联的表名
    /// </summary>
    public string? CorrespondingTable { get; set; }

    /// <summary>
    /// 关联的类型
    /// </summary>
    public string? CorrespondingType { get; set; }

    /// <summary>
    /// 关联的Where字段名
    /// </summary>
    public string? WhereField { get; set; }

    /// <summary>
    /// 关联的where字段值
    /// </summary>
    public string? WhereValue { get; set; }

    public PLCReadDataEditDto()
    {
    }

    public PLCReadDataEditDto(string pLCReadDataNo, string? pLCConfigNo, int startBit, Domain.Shared.Enums.DataType dataType, int length, string remarks)
    {
        PLCReadDataNo = pLCReadDataNo;
        PLCConfigNo = pLCConfigNo;
        StartBit = startBit;
        DataType = dataType;
        Length = length;
        Remarks = remarks;
        IsDependency = YesNo.否;
    }

    public PLCReadDataEditDto(string pLCReadDataNo, string? pLCConfigNo, int startBit, Domain.Shared.Enums.DataType dataType, int length, string remarks, string correspondingTable, string correspondingField, string whereField, string whereValue)
    {
        PLCReadDataNo = pLCReadDataNo;
        PLCConfigNo = pLCConfigNo;
        StartBit = startBit;
        DataType = dataType;
        Length = length;
        Remarks = remarks;
        CorrespondingField = correspondingField;
        CorrespondingTable = correspondingTable;
        WhereField = whereField;
        WhereValue = whereValue;
    }

    public PLCReadDataEditDto(string pLCReadDataNo, string? pLCConfigNo, int startBit, Domain.Shared.Enums.DataType dataType, int length, string remarks, string correspondingType, string correspondingTable, string correspondingField, string whereField, string whereValue)
    {
        PLCReadDataNo = pLCReadDataNo;
        PLCConfigNo = pLCConfigNo;
        StartBit = startBit;
        DataType = dataType;
        Length = length;
        Remarks = remarks;
        IsDependency = YesNo.是;
        CorrespondingField = correspondingField;
        CorrespondingTable = correspondingTable;
        CorrespondingType = correspondingType;
        WhereField = whereField;
        WhereValue = whereValue;
    }

    public PLCReadDataEditDto(string pLCReadDataNo, string? pLCConfigNo, int startBit, Domain.Shared.Enums.DataType dataType, int length, string remarks, string correspondingType, string whereField, string whereValue)
    {
        PLCReadDataNo = pLCReadDataNo;
        PLCConfigNo = pLCConfigNo;
        StartBit = startBit;
        DataType = dataType;
        Length = length;
        Remarks = remarks;
        IsDependency = YesNo.是;
        CorrespondingType = correspondingType;
        WhereField = whereField;
        WhereValue = whereValue;
    }
}